package com.jcl.recruit.console.db.logic;

import com.jcl.core.utils.BaseUtils;
import com.jcl.recruit.console.ConsoleDbCorpDao;
import com.jcl.recruit.console.mapper.ConsoleDbCorpMapper;
import com.jcl.recruit.console.model.ConsoleDbCorp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @ClassName DbCorpLogic
 * @Author yyliu
 * @Date 2018/12/24 9:53
 * @Version 1.0
 **/
@Component
public class DbCorpLogic {

    @Autowired
    private ConsoleDbCorpDao consoleDbCorpDao;

    public void initDbCorp(String serverName,
                            String prefix,
                            Integer corpStart,
                            Integer corpEnd) {
        List<ConsoleDbCorp> list = new ArrayList();
        Date date = new Date();
        for (int i = corpStart; i <= corpEnd; i ++) {
            ConsoleDbCorp dbCorp = new ConsoleDbCorp();
            String corpCode = BaseUtils.madeCorpCode(prefix, i);
            dbCorp.setCorpCode(corpCode);
            dbCorp.setServerName(serverName);
            dbCorp.setStatus(1);
            dbCorp.setCreateTime(date);
            dbCorp.setUpdateTime(date);
            list.add(dbCorp);
        }
        consoleDbCorpDao.batchInsert(list);

    }


}
